package de.slothsoft.wasbinich.swingclient.res;

import java.util.Locale;
import java.util.MissingResourceException;

import de.slothsoft.android4swing.AndroidResourceBundle;

public final class AndroidMessages {

    static final String BUNDLE_DEFAULT = "res/values/strings"; //$NON-NLS-1$
    static final String BUNDLE_SETTINGS = "res/values/strings_settings"; //$NON-NLS-1$

    private static Locale locale = Locale.getDefault();

    public static String getDefault(String key) {
	try {
	    return AndroidResourceBundle.getAndroidBundle(BUNDLE_DEFAULT, locale).getString(key);
	} catch (MissingResourceException e) {
	    return '!' + key + '!';
	}
    }

    public static String getSettings(String key) {
	try {
	    return AndroidResourceBundle.getAndroidBundle(BUNDLE_SETTINGS, locale).getString(key);
	} catch (MissingResourceException e) {
	    return '!' + key + '!';
	}
    }

    public static void setLocale(Locale locale) {
	AndroidMessages.locale = locale;
    }

    public static Locale getLocale() {
	return locale;
    }

    private AndroidMessages() {
	// hide class
    }

}
